<% include ../header.ejs %>

<link rel="stylesheet" href="/stylesheets/app/evaluate/evaluate_servicedetail.css">

<header data-am-widget="header" data-am-sticky class="am-header am-header-default am-header-fixed"
        id="appTemplates-Nav">


    <div class="am-header-left am-header-nav">
        <a href="javascript:history.go(-1)" onClick="">

            <img class="am-header-icon-custom"
                 src="data:image/svg+xml;charset=utf-8,&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 12 20&quot;&gt;&lt;path d=&quot;M10,0l2,2l-8,8l8,8l-2,2L0,10L10,0z&quot; fill=&quot;%23fff&quot;/&gt;&lt;/svg&gt;"
                 alt=""/>
            <span class="am-header-nav-title">
                服务列表
            </span>
        </a>
    </div>

    <h1 class="am-header-title">
        <a href="#title-link" class="" id="Typeface-whitecolor">详情</a>
    </h1>


    <div class="am-header-right am-header-nav">
        <a id="custom-score-button" onClick="scoreClick()">
            <span class="am-header-nav-title">
                打分
              </span>
        </a>
    </div>


</header>

<!--标题-->
<% if(stype == "survey" || stype == "roadshow" || stype == "strategy"){ %>
<h2><%=info.companyName%></h2>
<div class="custom-title-box">
<span class="am-badge am-badge-secondary" style="background-color: transparent;color: black"><%= moment(info.startTime).format('YYYY-MM-DD') %>~<%= moment(info.finishTime).format('YYYY-MM-DD') %></span>

</div>
<div  class="custom-title-box">
    <span class="am-badge am-badge-secondary" style="background-color: transparent;color: black">行业类型:<%= info.industry.industryName %></span>
</div>


<%} else if (stype == "recommond" ){%>
<h2>股票代码:<%=info.stockCode%></h2>
<%} else if (stype == "other" ){%>
<h2><%=info.title%></h2>
<%}%>

<hr/>

<!--标签-->
<div class="custom-title-box">

    <!--打分-->
    <% if(info.score != null && info.score != ""){ %>
    <span class="am-badge am-badge-warning" id="custom-score-span"><%=info.score%></span>
    <%} else {%>
    <span class="am-badge am-badge-warning" id="custom-score-span" style="display:none"></span>
    <%}%>

    <!--卖方信息-->
    <span class="am-badge am-badge-success"><%=info.seller.name%></span>

    <!--各个服务基本信息-->
    <% if(stype == "survey"){ %>
    <span class="am-badge am-badge-success"><%=info.type%></span>
    <span class="am-badge am-badge-success"><%=info.range%></span>

    <%} else if (stype == "roadshow" ){%>
    <span class="am-badge am-badge-success"><%=info.type%></span>
    <span class="am-badge am-badge-success"><%=info.recommend%></span>

    <%} else if (stype == "strategy" ){%>
    <span class="am-badge am-badge-success"><%=info.range%></span>

    <%} else if (stype == "recommond" ){%>

    <%} else if (stype == "other" ){%>


    <%} %>

</div>

<hr/>

<!--内容-->
<article data-am-widget="paragraph"
         class="am-paragraph am-paragraph-default"
         data-am-paragraph="{ tableScrollable: true, pureview: true }">

    <!--各个服务内容-->
    <% if(stype == "survey"){ %>

    <%} else if (stype == "roadshow" ){%>

    <%} else if (stype == "strategy" ){%>

    <%} else if (stype == "recommond" ){%>
    <p>目标价:<%=info.targetPrice%></p>
    <p>卖出时间:<%= moment(info.sellingTime).format('YYYY-MM-DD hh:mm') %></p>

    <%} else if (stype == "other" ){%>
    <p>服务时间:<%= moment(info.serviceTime).format('YYYY-MM-DD hh:mm') %></p>

    <%} %>

    <p><%=info.content%></p>

</article>






<!--底部-->
<!--各个服务内容-->
<% if(stype == "survey"){ %>
<hr/>
<p class="am-text-sm"><span class="am-icon-phone am-icon-sm"></span><%=info.contactName%>:<%=info.contact%></p>
<p class="am-text-sm"><span class="am-icon-location-arrow am-icon-sm"></span><%=info.province%>,<%=info.city%>,<%=info.addr%></p>

<%} else if (stype == "roadshow" ){%>

<%} else if (stype == "strategy" ){%>

<%} else if (stype == "recommond" ){%>

<%} else if (stype == "other" ){%>

<%} %>







<!--打分输入框-->
<div class="am-modal am-modal-prompt" tabindex="-1" id="custom-prompt">
    <div class="am-modal-dialog">
        <div class="am-modal-hd">输入分数</div>
        <div class="am-modal-bd">
            <input type="text" class="am-modal-prompt-input" id="custom-prompt-input">
        </div>
        <div class="am-modal-footer">
            <span class="am-modal-btn" data-am-modal-cancel>取消</span>
            <span class="am-modal-btn" data-am-modal-confirm>提交</span>
        </div>
    </div>
</div>


<script>

    function scoreClick() {

        if ($('#custom-score-span').text() != ""){
            alert("当前服务已打过分")
        }else{
            $('#custom-prompt').modal({
                relatedElement: this,
                onConfirm: function (e) {
                    $('#custom-prompt-input').val("");
                    if (isNaN(e.data)){
                        alert('请输入0~100分数');
                        return;
                    }

                    var scoreInt = parseInt(e.data);
                    if (scoreInt < 0 || scoreInt > 100){
                        alert('请输入0~100分数');
                        return;
                    }

                    var options = {
                        url: 'updatescore',
                        type: 'post',
                        dataType: 'json',
                        data: {'score': e.data,
                                'rowId':'<%=info.rowId%>',
                                'scoreUid':'<%=uid%>',
                                'stype':'<%=stype%>'
                        },
                        error: function (request) {
                            alert("打分失败");
                        },
                        success: function (data) {
                            $('#custom-score-span').css('display','');
                            $('#custom-score-span').text(data.result.obj[0].score);
                            alert("打分成功");
                        }
                    };
                    $.ajax(options);


                },
                onCancel: function () {

                }
            });
        }
    }


</script>

<% include ../footer.ejs %>